<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <form name="form">
      <input name="file" type="file" />
      <button type="button" id="upBtn">上传</button>
    </form>
    <script>
      upBtn.onclick = function () {
        const xhr = new XMLHttpRequest();
        xhr.open("POST", "http://127.0.0.1:8081/up");

        xhr.onload = function () {
          console.log(xhr.response);
        };
        const fd = new FormData();
        fd.append("myfile", form.file.files[0]);
        fd.append("name", "jack");
        fd.append("age", 20);
        xhr.send(fd);
      };
    </script>
  </body>
</html>
